﻿using System.Linq;

using vurfu.DataContracts;
using vurfu.Linq;

namespace vurfu.Repositories
{
    public class PlaceRepository
    {
        public Place GetPlace(string placeId)
        {
            Place place;
            using (var connection = DataContextFactory.Create())
            {
                place = (from places in connection.GetTable<Place>()
                          where places.PlaceId == placeId
                          select places).First();
            }
            return place;
        }

        public void SavePlace(Place place)
        {
            using (var connection = DataContextFactory.Create())
            {
                connection.GetTable<Place>().InsertOnSubmit(place);
                connection.SubmitChanges();
            }
        } 
    }
}